package tresp.bthreads;

import java.util.logging.Logger;

import robocode.BulletHitBulletEvent;
import robocode.BulletHitEvent;
import robocode.BulletMissedEvent;
import tresp.coordinator.ICoordinator;
import tresp.utils.BThreadVote;
import tresp.utils.ITankInfo;
import tresp.utils.logging.MyLogger;


/**
 * <b>Kill</b>
 * 
 * 
 * @author <font color="blue">Maxim Kirilov</font>
 *
 */
public class Kill extends BThread {

    private static Logger logger = MyLogger.getLogger( Kill.class );
    
//    private double hit = 1D;
    
//    private double miss = 1D;
    
    private ITankInfo tankInfo;
    
    public Kill(ICoordinator<BThreadVote> coordinator) {
	super(coordinator);
	logger.info("Kill B-Thread created successfully");
	this.weight = 30D;
	
	tankInfo = coordinator.getTankInfo();
    }

    @Override
    public void vote() {
	
	if ( tankInfo.getEnergy() > 80){
	    coordinator.vote( createBThreadVote(BThreadType.PATTERN_MATCHER_TARGETING, weight, 5D) );
	    coordinator.vote( createBThreadVote(BThreadType.FACTORIZED_MOVE, weight, -5D) );
	}else if ( tankInfo.getEnergy() < 40){
	    coordinator.vote( createBThreadVote(BThreadType.PATTERN_MATCHER_TARGETING, weight, -5D) );
	    coordinator.vote( createBThreadVote(BThreadType.FACTORIZED_MOVE, weight, -5D) );
	}
//	logger.info("Hit ratio: "+ hit / (hit + miss));
	     
    }

    @Override
    public String getName() {
	return "Kill";
    }

    @Override
    public void onBulletHit(BulletHitEvent event){
//	hit++;
    }

    @Override
    public void onBulletHitBullet(BulletHitBulletEvent event){
//	miss++;
    }

    @Override
    public void onBulletMissed(BulletMissedEvent event){
//	miss++;
    }

}
